#include"lottery_sys.h"

Buyer_t* buy_lottery_center(Buyer_t* user)
{
	char chose;
	Lottery_t* lott_head = NULL;
	L_buyed_t* buyed_head = NULL;
	lott_head = load_lott();
	if(lott_head -> next == NULL)
	{
		printf("彩票未发行\n");
		printf("按回车键返回\n");
		cleaninput();
		//sleep(2);
		return NULL;
	}
	buyed_head = load_buyed_lott();
	if(lott_head == NULL)
	{
		printf("上一期已开奖，新一期未发布！");
		return 0;
	}
	//show_buylott_list(buyed_head);

	printf("\t\e[1;32m欢迎来到彩票信息中心\e[0m\n");
	while(1)
	{
		printf("\t请选择业务: ");
		scanf("%c",&chose);
		cleaninput();
		switch(chose)
		{
			case '1':
				printf("彩票池信息\n");
				show_lott_list(lott_head);
				break;
			case '2':
				printf("历史交易记录\n");
				show_hist_lott(user,buyed_head);
				break;
			case '3':
				printf("购买彩票（下注）\n");
				buy_lottery(user,lott_head,buyed_head);
				break;
			default:
				save_buylott_list(buyed_head);
				free_buylott_list(buyed_head);
				save_lott_list(lott_head);
				free_lott_list(lott_head);
				printf("返回\n");
				return NULL;
		}

	}

}
